package yl.hs.bmipfull.service.salemanage.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import yl.hs.bmipfull.daos.salemanage.ISaleContractAdditionalMoneyDao;
import yl.hs.bmipfull.pojo.salemanage.SaleContractAdditionalMoneyEntity;
import yl.hs.bmipfull.service.salemanage.ISaleContractAdditionalMoneyService;
import yl.hs.bmipfull.service.salemanage.ISaleContractProductsService;

import java.util.List;

/**
 * 作用:   <br/>
 * 创建时间: 2023-02-14 11:31 <br/>
 *
 * @author 吴高丰
 */
@Service
public class SaleContractAdditionalMoneyServiceImple extends SaleBaseService implements ISaleContractAdditionalMoneyService {
    @Autowired
    public ISaleContractAdditionalMoneyDao dao;
    @Override
    public List<SaleContractAdditionalMoneyEntity> queryListByContractSn(String contractSn) {
        var result =  dao.queryAdditional(contractSn);
        return result;
    }

    @Override
    public Integer updateSaleContractAdditional(String contractSn,List<SaleContractAdditionalMoneyEntity> entities) {
        var result = dao.deleteByContractSn(contractSn);
        entities.forEach(s->{
            dao.insertSaleContractAdditionalMoney(s);
        });
        return result;
    }

    @Override
    public Integer deleteByContractSn(String contractSn) {
        return dao.deleteByContractSn(contractSn);
    }
}
